package org.spice.servlet.tags;

import java.io.IOException;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.DynamicAttributes;

public 
class LabelTag extends BaseTag implements DynamicAttributes{

	private static final long serialVersionUID = 1L;

	
	private 
	String forRef;
	
	public 
	String getFor() {
		return forRef;
	}
	
	public 
	void setFor(String forRef) {
		this.forRef = forRef;
	}
	
	
	@Override
	public 
	void setDynamicAttribute(String uri, String localName, Object value)
			throws JspException {
		
	}

	@Override
	public 
	int writeTag(PageContext pageContext) {
		try {
			this.pageContext.getOut().append("<label for=\"" + getFor() + "\" >");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_BODY_INCLUDE;
	}
	
	@Override
	public int doEndTag() throws JspException {
		try {
			this.pageContext.getOut().append("</label>");
		} catch (IOException e) {
			e.printStackTrace();
		}
		return super.doEndTag();
	}
	

}
